<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<link rel="stylesheet" href="css/sidebar.css">
<%@ page import="org.hibernate.SessionFactory"%>
<%@ page import="org.hibernate.Session"%>
<%@ page import="java.util.List"%>
<%@ page import="hibernate.model.*"%>
<%@ page import="hibernate.util.HibernateUtil"%>
<%@ page import="hibernate.method.*"%>
<%@ page import="hibernate.method.UserMethods"%>
<div class="messages">

	<div style="text-align:center">
		<div class="title">
			<h3>WIADOMOŚCI</h3>
		</div>
	</div>
	<%
Integer user_id = (Integer) session.getAttribute("user_id");
response.setContentType("text/html");
SessionFactory sessionFactory = HibernateUtil.getSessionAnnotationFactory();
Session s= sessionFactory.openSession();
s.beginTransaction();
UserMethods um = new UserMethods();
if (user_id == null) {
%>
<div id="messages_content">Aby wyswietlic wiadomosci musisz byc zalogowany</div>
		<% } 

else
	if ("client".equals(um.getUserType(sessionFactory, s, user_id))){
	%>
	<div class="menu_simple">
		<ul>
			<li><a class="newMessage" href="index.jsp?page=messages&group=newMessage">NOWA</a></li>
			<li><a class="inbox" href="index.jsp?page=messages&group=inbox">ODEBRANE</a></li>
			<li><a class="sent" href="index.jsp?page=messages&group=sent">WYSŁANE</a></li>
		</ul>
	</div>

	<div id="messages_content">
	<jsp:include page="messages/messages_content.jsp" ></jsp:include>
		</div>

<% } s.getTransaction().commit();%>
</div>
